#/usr/bin/python
import os,sys,commande,time,gtk

class window(gtk.Window):
    def __init__(self,mac_spoof):
        gtk.Window.__init__(self,type=gtk.WINDOW_TOPLEVEL)
        self.set_title("Arp Spoofing")
        self.set_position(gtk.WIN_POS_CENTER)
        self.label=gtk.Label("Vous etes Spoofer!")
        self.label2=gtk.Label(mac_spoof)
        self.button=gtk.Button(None,gtk.STOCK_OK)
        self.button.connect("clicked",self.callback)
        self.boite=gtk.VBox()
        self.boite.pack_start(self.label)
        self.boite.pack_start(self.label2)
        self.boite.pack_start(self.button)
        self.add(self.boite)
        self.show_all()
        gtk.main()
    def callback(self,*args):
        self.destroy()
        gtk.main_quit()

def check_poof(mac_true,ipgateway):
    test_mac = commande.mac_address(ipgateway)
    if(test_mac == mac_true): 
        return (False, None)
    else : 
        return (True,test_mac)

def wait(ipgateway,mac_gateway_true):
    while True:
        verif,mac= check_poof(mac_gateway_true,ipgateway)
        if verif :
            break
        time.sleep(20)
    print "Arp Spoofing en cours !"
    return mac

if(__name__=="__main__"):
    ipgateway = commande.ip_gateway()
    mac_gateway_true = commande.mac_address(ipgateway)
    while True :
        mac_spoof = wait(ipgateway,mac_gateway_true)
        bot = window(mac_spoof)